package cn.tedu.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.Arrays;

@WebServlet("/ServletDemo05")
public class ServletDemo05 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doGet(request,response);
    }

    //当用户以
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //1.request解析请求参数 name=rose&pwd=123
        String s = request.getParameter("name");//获取name属性的值
        System.out.println(s);
        String p = request.getParameter("pwd");
        System.out.println(p);

        //1.2获取到多个值
        String[] hobbies = request.getParameterValues("hobby");
        String s1 = Arrays.toString(hobbies);
        System.out.println(s1);
    }
}
